<?php
use HyperfStore\Route\Route;

Route::get('/images', 'IndexController@images');

Route::get('/config', 'IndexController@config');
Route::post('/search', 'IndexController@search');
Route::post('/code', 'IndexController@code');
Route::post('/login', 'IndexController@login');
Route::post('/register', 'IndexController@register');
Route::post('/password', 'IndexController@password');

Route::post('/upload', 'IndexController@upload');

Route::get('/news', 'NewsController@index');
Route::get('/news/{id}', 'NewsController@info');

Route::get('/video', 'VideoController@index');
Route::get('/video/{id}', 'VideoController@info');

Route::get('/product', 'ProductController@index');
Route::get('/product/{id}', 'ProductController@info');

Route::get('/mall', 'MallController@index');
Route::get('/mall/goods', 'MallController@goods');
Route::get('/mall/goods/{id}', 'MallController@info');

// 支付回调
Route::post('/order/alipay/notify/{id}', 'OrderController@alipayNotify');
Route::post('/order/unionpay/notify/{id}', 'OrderController@unionpayNotify');
Route::post('/mall/order/alipay/notify/{id}', 'MallOrderController@alipayNotify');
        
Route::middleware('auth')->group(function () {
    // 用户
    Route::get('/user', 'UserController@info');
    Route::get('/user/list', 'UserController@list');
    Route::get('/user/log', 'UserController@log');
    
    // 收货地址
    Route::get('/user/address', 'UserAddressController@index');
    Route::get('/user/address/default', 'UserAddressController@default');
    Route::post('/user/address', 'UserAddressController@create');
    Route::put('/user/address/{id}', 'UserAddressController@update');
    Route::delete('/user/address/{id}', 'UserAddressController@delete');
    Route::post('/user/address/check/{id}', 'UserAddressController@check');
    
    Route::middleware('user_limit')->group(function () {
        // 资产互换
        Route::post('/user/to', 'UserController@to');
        // 钱包
        Route::post('/user/wallet', 'UserController@wallet');
        Route::post('/user/wallet/out', 'UserController@walletOut');
    });
    
    // 转帐日志
    Route::get('/user/transfer', 'UserTransferController@index');
    Route::middleware('user_limit')->group(function () {
        // 转帐操作
        Route::post('/user/transfer/{id}', 'UserTransferController@to');
    });
    
    // 提现
    Route::get('/user/out', 'UserOutController@index');
    Route::middleware('user_limit')->group(function () {
        // 申请操作
        Route::post('/user/out', 'UserOutController@to');
    });
    
    // 订单
    Route::get('/order/user', 'OrderController@user');
    Route::get('/order/remain', 'OrderController@remain');
    Route::middleware('user_limit')->group(function () {
        // 购买商品操作
        Route::post('/order/{id}', 'OrderController@index');
        // 支付订单
        Route::post('/order/unionpay/{id}', 'OrderController@unionpay');
        // 支付宝支付
        Route::post('/order/alipay/{id}', 'OrderController@alipay');
        // 余额支付
        Route::post('/order/money/{id}', 'OrderController@money');
        // 关闭订单
        Route::get('/order/no/{id}', 'OrderController@no');
        // 确认订单
        Route::get('/order/ok/{id}', 'OrderController@ok');
        // 每日签到
        Route::get('/order/day', 'OrderController@day');
    });
    
    // 购物订单
    Route::get('/mall/order/user', 'MallOrderController@user');
    Route::middleware('user_limit')->group(function () {
        // 购买商品操作
        Route::post('/mall/order/{id}', 'MallOrderController@index');
        // 支付宝支付
        Route::post('/mall/order/alipay/{id}', 'MallOrderController@alipay');
        // 余额支付
        Route::post('/mall/order/money/{id}', 'MallOrderController@money');
        // 关闭订单
        Route::get('/mall/order/no/{id}', 'MallOrderController@no');
        // 确认订单
        Route::get('/mall/order/ok/{id}', 'MallOrderController@ok');
    });
    
    // 我的店铺 
    Route::get('/mall/shop', 'MallShopController@index');
    // 店铺商品
    Route::get('/mall/shop/goods', 'MallShopController@goods');
    // 创建店铺商品
    Route::post('/mall/shop/goods', 'MallShopController@goodsCreate');
    // 删除店铺商品
    Route::delete('/mall/shop/goods/{id}', 'MallShopController@goodsDelete');
    // 店铺商品库存
    Route::post('/mall/shop/goods/count/{id}', 'MallShopController@goodsCount');
    // 店铺订单
    Route::get('/mall/shop/order', 'MallShopController@order');
    // 店铺订单发货
    Route::post('/mall/shop/order/express/{id}', 'MallShopController@orderExpress');
    Route::middleware('user_limit')->group(function () {
        // 申请店铺
        Route::post('/mall/shop', 'MallShopController@create');
    });
});